// api.js
import http from "../http/index.js";

export default {
	//根据用户账号获取车辆信息
	getCarInfoByUserName: {
		name: "根据用户账号获取车辆信息",
		url: "/repair/mycar/info",
		call: async function(params = {}) {
			// const url = this.url + `/info/${userName}`;
			return await http.get(this.url, params);
		},
	},
	//添加车辆信息
	addCarInfo: {
		name: "添加车辆信息",
		url: "/repair/mycar/add",
		call: async function(data = {}) {
			// const url = this.url +  `/add`;
			return await http.post(this.url, data);
		},
	},
	//删除车辆信息
	deleteCarInfo: {
		name: "删除车辆信息",
		url: `/repair/mycar/delete/`,
		call: async function(id) {
			// const url = this.url +  `/delete/${id}`;
			return await http.delete(this.url + id, {});
		},
	},
	//修改车辆信息
	updateCarInfo: {
		name: "修改车辆信息",
		url: "/repair/mycar/update",
		call: async function(data = {}) {
			// const url = this.url +  `/update`;
			return await http.put(this.url, data);
		}
	},
	// 根据用户账号获取默认车辆（对应后端接口 /user/car/getCarUuidByUsername）
	getCarUuidByUsername: {
		name: "根据用户账号获取默认车辆",
		url: "/repair/user/car/getCarUuidByUsername",
		call: async function(params = {}) {
			return await http.get(this.url, params);
		}
	},
	// 设置默认车辆（对应后端接口 /user/car/setCarUuidByUsername）
	setCarUuidByUsername: {
		name: "设置默认车辆",
		url: "/repair/user/car/setCarUuidByUsername",
		call: async function(data = {}) {
			return await http.put(this.url, data);
		}
	}
};